home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / falcon / programm.ing / nt_dsp1.lzh / NT_DSP1.MSA / FLOAT / FPSUB.ASM < prev   
Assembly Source File  |  1989-01-24  |  3KB  |  98 lines

  1.  
  2. ;
  3. ; This program originally available on the Motorola DSP bulletin board.
  4. ; It is provided under a DISCLAIMER OF WARRANTY available from
  5. ; Motorola DSP Operation, 6501 Wm. Cannon Drive W., Austin, Tx., 78735.
  6. ; Last Update 15 Oct 87   Version 2.1
  7. ;
  8. fpsub   ident   2,1
  9. ;
  10. ; MOTOROLA DSP56000/1 FPLIB - VERSION 2
  11. ;
  12. ; FPSUB - FLOATING POINT SUBTRACTION SUBROUTINE
  13. ;
  14. ; Entry points: fsub_xa R = A - X
  15. ;               fsub_xy R = Y - X
  16. ;
  17. ;       m = 24 bit mantissa (two's complement, normalized fraction)
  18. ;
  19. ;       e = 14 bit exponent (unsigned integer, biased by +8191)
  20. ;
  21. ; Input variables:
  22. ;
  23. ;   X   x1 = mx  (normalized)
  24. ;       x0 = ex
  25. ;
  26. ;   Y   y1 = my  (normalized)
  27. ;       y0 = ey
  28. ;
  29. ;   A   a2 = sign extension of ma
  30. ;       a1 = ma  (normalized)
  31. ;       a0 = zero
  32. ;
  33. ;       b2 = sign extension of ea (always zero)
  34. ;       b1 = ea
  35. ;       b0 = zero
  36. ;
  37. ; Output variables:
  38. ;
  39. ;   R   a2 = sign extension of mr
  40. ;       a1 = mr  (normalized)
  41. ;       a0 = zero
  42. ;
  43. ;       b2 = sign extension of er (always zero)
  44. ;       b1 = er
  45. ;       b0 = zero
  46. ;
  47. ; Error conditions:     Set CCR L=1 if floating point overflow.  Result
  48. ;                       is set to the maximum floating point value of the
  49. ;                       correct sign.  The CCR L bit remains set until
  50. ;                       cleared by the user.
  51. ;
  52. ;                       Set CCR L=1 if floating point underflow.  Result
  53. ;                       is set to floating point zero.  The CCR L bit
  54. ;                       remains set until cleared by the user.
  55. ;
  56. ; Assumes n0, m0, shift constant table and scaling modes
  57. ; initialized by previous call to the subroutine "fpinit".
  58. ;
  59. ; Alters Data ALU Registers
  60. ;       a2      a1      a0      a
  61. ;       b2      b1      b0      b
  62. ;       x1      x0      y1      y0
  63. ;
  64. ; Alters Address Registers
  65. ;       r0
  66. ;
  67. ; Alters Program Control Registers
  68. ;       pc      sr                                                  
  69. ;
  70. ; Uses 0 locations on System Stack
  71. ;
  72. ;
  73. fsub_xy tfr     y0,b    y1,a            ;get ey, my
  74. fsub_xa sub     x0,b    b1,y1           ;compare delta = ea - ex, save ea
  75.         jge     _dpos                   ;jump if ea >= ex
  76. ;
  77. ; ea < ex
  78. ;
  79. _dneg   tfr     x1,a    a1,x1           ;swap ma with mx
  80.         neg     a       x0,y1           ;negate mx, save ex
  81.         abs     b       fp_space:fp_23,y0       ;negate er', get delta limit
  82.         cmp     y0,b    b1,r0           ;check delta limit, save delta
  83.         jle     addm                    ;jump if delta =< 23
  84.         tst     a       x0,r0           ;get er', setup CCR for norm
  85.         jmp     norm1                   ;normalize result
  86. ;
  87. ; ea >= ex
  88. ;
  89. _dpos   move            fp_space:fp_23,y0       ;get delta limit
  90.         cmp     y0,b    b1,r0           ;check delta limit, save delta
  91.         jgt     done1                   ;jump if delta > 23
  92.         move    fp_space:(r0+n0),x0     ;lookup shift constant s
  93.         mac     x1,x0,a y1,r0           ;denormalize by s, 
  94.                                         ;  subtract mantissa, get er'
  95.         jmp     norm                    ;normalize result
  96.  
  97.